<template>
  <div>
    <a-modal v-model:visible="visible" title="医废查看" :footer="null" width="40%"> 
        <div class="timeline">
        <div class="timeline-item timeline-l" v-if="dataList[0]">
          <div class="timeline-item-content">
            <div class="headline">基本信息</div>
            <div class="content">
              <div class="item">
                <span>医废编号：<span>{{dataList[0].wasteCode}}</span></span>
              </div>
              <div class="item">
                <span>科室：{{dataList[0].hospitalDepartName}}</span>
              </div>
              <div class="item">
                <span>医废类型：{{dataList[0].wasteClassifyName}}</span>
              </div>
            </div>
          </div>
          <div class="line l-pos">
            <img
              src="../../../../assets/8.png"
              alt=""
            >
          </div>
        </div>
        <div class="timeline-item timeline-r" v-if="dataList[1]">
          <div class="timeline-item-content">
            <div class="headline">收集</div>
            <div class="content">
              <div class="item">
                <span>收集人：<span>{{dataList[1].collectStaffName}}</span></span>
              </div>
              <div class="item">
                <span>科室交接人：{{dataList[1].handUserStaffName}}</span>
              </div>
              <div class="item">
                <span>称重质量：{{dataList[1].weight}}KG</span>
              </div>
              <div class="item">
                <span>收集时间：{{dataList[1].time}}</span>
              </div>
            </div>
          </div>
          <div class="line r-pos">
            <img
              src="../../../../assets/7.png"
              alt=""
            >
          </div>
        </div>
        <div class="timeline-item timeline-l" v-if="dataList[2]">
          <div class="timeline-item-content">
            <div class="headline">入库</div>
            <div class="content">
              <div class="item">
                <span>入库人：<span>{{dataList[2].placeUserStaffName}}</span></span>
              </div>
              <div class="item">
                <span>暂存点：{{dataList[2].hospitalPlaceName}}</span>
              </div>
              <div class="item">
                <span>集装箱：{{dataList[2].wasteBoxCode}}</span>
              </div>
              <div class="item">
                <span>称重质量：{{dataList[2].weight}}</span>
              </div>
              <div class="item">
                <span>入库时间：{{dataList[2].time}}</span>
              </div>
            </div>
          </div>
          <div class="line l-pos">
            <img
              src="../../../../assets/9.png"
              alt=""
            >
          </div>
        </div>
        <div class="timeline-item timeline-r" v-if="dataList[3]">
          <div class="timeline-item-content">
            <div class="headline">出库</div>
            <div class="content">
              <div class="item">
                <span>出库人：<span>{{dataList[3].placeUserStaffName}}</span></span>
              </div>
              <div class="item">
                <span>医废公司收集人：{{dataList[3].userRevicerName}}</span>
              </div>
              <div class="item">
                <span>集装箱：{{dataList[3].wasteBoxCode}}</span>
              </div>
              <div class="item">
                <span>称重质量：{{dataList[3].weight}}</span>
              </div>
              <div class="item">
                <span>出库库时间：{{dataList[2].time}}</span>
              </div>
            </div>
          </div>
          <div class="line r-pos">
            <img
              src="../../../../assets/6.png"
              alt=""
            >
          </div>
        </div>
      </div>
       </a-modal>
  </div>
</template>
<script>
import {
  getCurrentInstance,
  reactive,
  ref,
  toRefs,
} from "vue";
import * as medicalWasteApi from "@/api/medicalWaste";
import { getUserInfo } from "@/utils/auth";
export default {
  setup() {
    const { proxy } = getCurrentInstance();
    const visible = ref(false);
    const dataListref = reactive({ dataList: [] });

    const handleWastDetails = (id) => {
      medicalWasteApi.getListByWasteId(id).then((res) => {
        if (res && res.success) {
          if (res.data && res.data.length != 0) {
            dataListref.dataList = [];
            for (let f of res.data) {
              dataListref.dataList.unshift(f);
            }
          }
        }
      });
    };

    //初始化弹框
    const openModal = (_row) => {
      visible.value = true;
       proxy.$nextTick(() => {
        handleWastDetails(_row.id);
      });
    };

    return {
      visible,
      proxy,
      ...toRefs(dataListref),
      handleWastDetails,
      openModal,
    }
  },
};
</script>
<style lang="scss" scoped>
  .timeline {
  position: relative;
  .timeline-item {
    width: 100%;
    display: flex;
    position: relative;
    .timeline-item-content {
      width: 35%;
      background: #f2f2f2;
      position: relative;
      border-radius: 3px;
      .headline {
        font-size: 16px;
        color: #333;
        font-weight: bold;
        padding: 0 10px;
        line-height: 2;
        border-bottom: 1px solid #adadad;
      }
      .content {
        padding: 10px;
        line-height: 1.8;
        font-size: 14px;
        .item {
          overflow: hidden; //超出的文本隐藏
          text-overflow: ellipsis; //溢出用省略号显示
          white-space: nowrap; //溢出不换行
        }
      }
    }
  }
  .timeline-l {
    justify-content: flex-start;
    position: relative;
    left: 8%;
  }
  .timeline-r {
    justify-content: flex-end;
    position: relative;
    right: 8%;
  }
  .line {
    position: absolute;
    width: 32px;
    height: 100%;
    &::after {
      position: absolute;
      content: "";
      width: 2px;
      height: calc(100% - 32px);
      top: 32px;
      background: #f2f2f2;
      left: 15px;
    }
    img {
      width: 32px;
      z-index: 12;
    }
  }
  .l-pos {
    left: 40%;
  }
  .r-pos {
    left: 56%;
  }
}
</style>